#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char *argv[])
{
    int fd,ret;
    int key_val;

    fd=open(argv[1], O_RDWR);
    if(fd<0){
        printf("ERROR: file %s open failed!\n", argv[1]);
        return -1;
    }


    for(;;){
        read(fd, &key_val, sizeof(int));
        if(key_val==0x0){
            printf("Key Pressed!\n");
        }
        else if(key_val==0x1){
            printf("Key Released!\n");
        }
    }

    close(fd);
    return 0;
}